<template>
  <div class="ele-body">
    <el-card shadow="none" style="margin-bottom: 20px;font-weight: 800">
      投诉日报
    </el-card>
    <el-row :gutter="20" >
      <el-col :span="24" :lg="12">
        <el-card shadow="none">
          <template #header>客户投诉趋势</template>
          <main>
            <el-table border size="mini"
                      :header-cell-style="{'text-align':'center','background-color':'rgba(233, 240, 252)'}"
                      :cell-style="{'text-align':'center','color':'#055bdb'}"
                      :data="tableData"
            >
              <el-table-column label="责任单位" prop="date" width="80">
              </el-table-column>
              <el-table-column label="招标（单数）" prop="date" width="100">
              </el-table-column>
              <el-table-column label="汇总" prop="name" width="50">
              </el-table-column>
              <el-table-column label="1818周（5.1-5.6)" prop="date">
              </el-table-column>
              <el-table-column label="1818周（5.1-5.6)" prop="date">
              </el-table-column>
              <el-table-column label="1818周（5.1-5.6)" prop="date">
              </el-table-column>
              <el-table-column label="1818周（5.1-5.6)" prop="date">
              </el-table-column>
            </el-table>
          </main>
          <div class="topLeftChart">
            <topLeftChart ref="topLeftChart"></topLeftChart>
          </div>
        </el-card>

      </el-col>
      <el-col :span="24" :lg="12">
        <el-card shadow="none">
          <template #header>客户投诉趋势</template>
          <div class="customerCard">

            <main>
              <el-table border size="mini"
                        :header-cell-style="{'text-align':'center','background-color':'rgba(233, 240, 252)'}"
                        :cell-style="{'text-align':'center'}"
                        :data="tableData1"
              >
                <el-table-column label="地址">
                  <el-table-column label="产品零件" prop="name" width="80" >
                  </el-table-column>
                  <el-table-column label="累计投诉次数" prop="name" width="100" >
                  </el-table-column>
                </el-table-column>
              </el-table>
            </main>
            <div class="topRightChart">
              <topRightChart ref="topRightChart"></topRightChart>
            </div>
          </div>

        </el-card>

      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="24" :lg="12">
        <el-card shadow="none">
          <template #header>本月客户累计排名前10名</template>
          <div class="customerCard">

            <main>
              <el-table border size="mini"
                        :header-cell-style="{'text-align':'center','background-color':'rgba(233, 240, 252)'}"
                        :cell-style="{'text-align':'center'}"
                        :data="tableData1"
              >
                <el-table-column label="地址">
                  <el-table-column label="产品零件" prop="name" width="80" >
                  </el-table-column>
                  <el-table-column label="累计投诉次数" prop="name" width="100" >
                  </el-table-column>
                </el-table-column>
              </el-table>
            </main>
            <div class="topRightChart">
              <bottomLeftChart ref="bottomLeftChart"></bottomLeftChart>
            </div>
          </div>
        </el-card>

      </el-col>
      <el-col :span="24" :lg="12">
        <el-card shadow="none">
          <template #header>本月缺陷累计排名前10位</template>
          <div class="customerCard">
            <main>
              <el-table border size="mini"
                        :header-cell-style="{'text-align':'center','background-color':'rgba(233, 240, 252)'}"
                        :cell-style="{'text-align':'center'}"
                        :data="tableData1"
              >
                <el-table-column label="地址">
                  <el-table-column label="产品零件" prop="name" width="80" >
                  </el-table-column>
                  <el-table-column label="累计投诉次数" prop="name" width="100" >
                  </el-table-column>
                </el-table-column>
              </el-table>
            </main>
            <div class="topRightChart">
              <bottomRightChart ref="bottomRightChart"></bottomRightChart>
            </div>
          </div>
        </el-card>

      </el-col>
    </el-row>
  </div>
</template>

<script>
import topLeftChart from "@/views/reports/customer-complaints/components/topLeftChart.vue";
import topRightChart from "@/views/reports/customer-complaints/components/topRightChart.vue";
import bottomLeftChart from "@/views/reports/customer-complaints/components/bottomLeftChart.vue";
import bottomRightChart from "@/views/reports/customer-complaints/components/bottomRightChart.vue";

export default {
  name: "",
  components: {topLeftChart, topRightChart, bottomLeftChart, bottomRightChart},
  data() {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }],
      tableData1: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      },
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },]
    }
  },
  activated() {
    this.init()
    document.querySelector(".ele-admin-content-view").style.height = "100%"
    this.refresh = true
    // console.log()
  },
  deactivated() {
    document.querySelector(".ele-admin-content-view").style.height = "auto"
  },
  methods: {
    init() {
      window.addEventListener("resize", this.resizeList)
      this.$once('hook:beforeDestroy', function () {
        window.removeEventListener('resize', this.resizeList)
      })
    },
    resizeList(event, args = this.$children) {
      const components = args
      if (components.length > 0) {
        components.forEach(component => {
          if (component.myEcharts) {
            component.myEcharts.resize()
          } else if (component.$children.length > 0) {
            this.resizeList(event, component.$children)
          }
        })
      }
    },
    cellStyle({row,columnIndex}){
      console.log(row)
      if ( columnIndex === 1){
        return 'color : green'
      }
    },
  },
  mounted() {
    this.init()
    this.$refs.topLeftChart.initChart()
    this.$refs.topRightChart.initChart()
    this.$refs.bottomLeftChart.initChart()
    this.$refs.bottomRightChart.initChart()
  }
}
</script>

<style lang="scss" scoped>
@import "src/styles/conversion.scss";
.ele-body{
  font-size: px2vh(18);
}
.el-row {
  margin-bottom: px2vh(20);

  &:last-child {
    margin-bottom: 0;
  }
}

.topLeftChart {
  height: px2vh(230);
  width: 100%;
}
.topRightChart{
  height: px2vh(360);
  width: 75%;
}

.customerCard {
  display: flex;
}
</style>
